cmake_minimum_required(VERSION 2.8)
project(kratos)

set(CMAKE_C_COMPILER "clang")
set(CMAKE_CXX_COMPILER "clang++")
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g -Wno-invalid-source-encoding")
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -Wno-invalid-source-encoding")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -std=c++11")

add_definitions("-m64 -g -Wall -Wno-overloaded-virtual -fstack-protector -fstack-protector-all")

INCLUDE_DIRECTORIES(
  ./grid/thirdparty/
)

SET(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib) 

aux_source_directory(. SRC_LIST)
aux_source_directory(./event SRC_LIST)
aux_source_directory(./grid SRC_LIST)
aux_source_directory(./grid/actor SRC_LIST)
aux_source_directory(./logger SRC_LIST)
aux_source_directory(./network SRC_LIST)
aux_source_directory(./entity SRC_LIST)
aux_source_directory(./util SRC_LIST)
aux_source_directory(./mysql SRC_LIST)
aux_source_directory(./redis SRC_LIST)
aux_source_directory(./network/thirdparty/kcp SRC_LIST)
aux_source_directory(./network/thirdparty/khttp/internal SRC_LIST)
aux_source_directory(./thirdparty/md5 SRC_LIST)
aux_source_directory(./thirdparty/json SRC_LIST)
aux_source_directory(./thirdparty/mysql/internal SRC_LIST)

add_library(
	kratos_core
	${SRC_LIST}	
	./network/thirdparty/enet/callbacks.c
	./network/thirdparty/enet/compress.c
	./network/thirdparty/enet/host.c
	./network/thirdparty/enet/list.c
	./network/thirdparty/enet/packet.c
	./network/thirdparty/enet/peer.c
	./network/thirdparty/enet/protocol.c
	./network/thirdparty/enet/unix.c	
	./network/thirdparty/knet/address.c
	./network/thirdparty/knet/buffer.c
	./network/thirdparty/knet/channel.c
	./network/thirdparty/knet/channel_ref.c
	./network/thirdparty/knet/dlist.c
	./network/thirdparty/knet/hash.c
	./network/thirdparty/knet/ip_filter.c
	./network/thirdparty/knet/logger.c
	./network/thirdparty/knet/loop.c
	./network/thirdparty/knet/loop_balancer.c
	./network/thirdparty/knet/loop_impl.c
	./network/thirdparty/knet/loop_profile.c
	./network/thirdparty/knet/misc.c
	./network/thirdparty/knet/rb_tree.c
	./network/thirdparty/knet/ringbuffer.c
	./network/thirdparty/knet/stream.c
	./network/thirdparty/knet/timer.c
	./network/thirdparty/knet/trie.c
	./network/thirdparty/knet/version.c
)

target_link_libraries(
	kratos_core
	libhiredis.a
	-lpthread
	-lmysqlclient
	-lrt
	-ldl
)

INSTALL(TARGETS kratos_core DESTINATION lib)
